package org.com.app.knock.view;
import org.com.app.knock.fragment.FriendFragment;
import org.com.app.knock.fragment.SearchFragment;

import z.lib.base.BaseItem;
import z.lib.base.BaseView;
import z.lib.base.LogUtils;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

import com.app.knock.db.AvataList;
import com.knock.app.R;

public class SearchFriendItemView extends BaseView implements OnClickListener {
	private static final String TAG = "SearchFriendItemView";
	Context ctx;
	public SearchFriendItemView(Context context) {
		super(context);
		init(R.layout.search_list_item);
		this.ctx = context;
	}

	public SearchFriendItemView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(R.layout.search_list_item);
	}

	@Override
	public void init(int res) {
		super.init(res);
	}

	@Override
	public void refresh() {
		super.refresh();
		setText( ((BaseItem) getData()).getString("name"),
				R.id.mTextView1);
		String avatar_id 	= ((BaseItem) getData()).getString("avatar_id");
		String avatar 		= ((BaseItem) getData()).getString("avatar");
		if(!"".equals(avatar)){
			ImageView imageView = (ImageView) findViewById(R.id.imageView1);
			FriendFragment.imageLoader.DisplayImage2(avatar, imageView);
		}else if(!"".equals(avatar_id)){
			String avata = new AvataList(ctx).getAvata(avatar_id);
//			LogUtils.e(TAG, avatar_id +"===avata===" + avata);
			ImageView imageView = (ImageView) findViewById(R.id.imageView1);
			SearchFragment.imageLoader.DisplayImage2(avata, imageView);
		}
	}

	@Override
	public void onClick(View v) {
	}

}